<!-- Home.vue文件 -->
<template>
  <div class="home-container">
    <h3>Home组件</h3>
    <router-link :to="{ name: 'MovieDetails', params: { id: 3 } }"
      >跳转到MovieDetails组件</router-link>
    <hr/>
    <a href="#" @click.prevent="gotoMovie(3)">跳转到MovieDetails组件</a>
    <hr />
    <a href="#" @click.prevent="replaceMovie(3)">跳转到MovieDetails组件(replace)</a>
  </div>
</template>
<script setup>
import { useRouter } from "vue-router";
const router = useRouter();
const gotoMovie = (movieId) => {
  router.push({
    name: "MovieDetails",
    params: { id: movieId },
  });
};
const replaceMovie = (movieId) => {
  router.replace({
    name: "MovieDetails",
    params: { id: movieId },
  });
};
</script>

<style scoped>
.home-container {
  min-height: 150px;
  background-color: #f2f2f2;
  padding: 15px;
}
</style>
